﻿using System;
using System.Web.Mvc;
using NUnit.Framework;
using WeBlog.Controllers;
using WeBlog.DataContext;
using WeBlog.Interfaces;
using WeBlog.Models;
using WeBlog.Repositories;
using WeBlog.Services;
using WeBlog.Tests.Helpers;
using WeBlog.Tests.Mocks;

namespace WeBlog.Tests.Controllers
{
    [TestFixture]
    public class HomeControllerTests
    {
        private IUnitOfWork _unitOfWork;
        private IEmailService _emailService;
        
        [SetUp]
        public void Setup()
        {
            _unitOfWork = new InMemoryUnitOfWork();
            _emailService = new FakeEmailService();
        }

        [Test]
        public void Contact_Action_Should_Return_Valid_Model()
        {
            //Arrange
            var controller = new HomeController(_unitOfWork, _emailService);           

            //Act
            var result = controller.Contact() as ViewResult;

            //Assert
            Assert.IsNotNull(result.ViewData.Model);
            Assert.IsInstanceOf(typeof(ContactViewModel), result.ViewData.Model);
        }

    }
}